﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Company.Shell.Converters
{
    public class DoubleTohhmmConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // value是double类型的小时数，转换成hh:mm格式的字符串
            if (value is double d)
            {
                int totalMinutes = (int)d;
                int hours = totalMinutes / 60;
                int minutes = totalMinutes % 60;
                return $"{hours:D2}:{minutes:D2}";// D2表示两位数，不足补0
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
